package com.novacloud.fresh.controller.register;


import com.novacloud.fresh.controller.util.UserValidator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.DataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;


import javax.servlet.http.HttpSession;
import javax.validation.Valid;

/**
 * @param
 * @author <a href="mailto:huzhanjun@novacloud.com">huzj</a>
 * @version : 1.0
 * @date 2015-12-29 18:49
 */
@Controller
@RequestMapping(value = "/register")
public class RegisterController {

//    @Autowired
//    private UserService userService;
//
//    Log log = LogFactory.getLog(User.class);
//
//    //注册页
//    @RequestMapping(value = "/web-register.html")
//    public ModelAndView webRegister(User user) {
//        return new ModelAndView("register/web-register");
//    }
//
//    @InitBinder
//    public void initbinder(DataBinder binder){
//        binder.setValidator(new UserValidator());
//    }
//    //确认注册
//    @RequestMapping(value = "/enter-register.html")
//    public ModelAndView enterRegister(@Valid User user, BindingResult result) {
//        if(result.hasErrors())
//            return new ModelAndView("register/web-register");
//        try {
//                userService.insert(user);
//                return new ModelAndView("register/success-register");
//
//        } catch (Exception e) {
//            return new ModelAndView("register/web-register");
//        }
//    }
//
//    //验证码
//    @RequestMapping(value = "/check-register.html")
//    @ResponseBody
//    public Boolean checkRegister(String code,User user, HttpSession session) {
//        String correct = (String) session.getAttribute("code");
//        Boolean result = code.equalsIgnoreCase(correct);
//        return result;
//    }

}
